<html>
<head><meta charset="utf-8"><title>multiple suggestions for diagnostics doesn&#x27;t work · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/multiple.20suggestions.20for.20diagnostics.20doesn&#x27;t.20work.html">multiple suggestions for diagnostics doesn&#x27;t work</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="201324047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/multiple%20suggestions%20for%20diagnostics%20doesn%27t%20work/near/201324047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/multiple.20suggestions.20for.20diagnostics.20doesn&#x27;t.20work.html#201324047">(Jun 18 2020 at 20:47)</a>:</h4>
<p>How do I emit multiple suggestions for a diagnostic?</p>
<p>Right now, my code looks like:</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">err_duplicate_option</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="p">(</span><span class="n">p</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">Parser</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">symbol</span>: <span class="nc">Symbol</span><span class="p">,</span><span class="w"> </span><span class="n">span</span>: <span class="nc">Span</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">err</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">p</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">sess</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">span_diagnostic</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">struct_span_err</span><span class="p">(</span><span class="n">span</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">format</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;the `{}` option was already provided&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">symbol</span><span class="p">));</span><span class="w"></span>
<span class="w">    </span><span class="n">err</span><span class="p">.</span><span class="n">span_suggestion</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="n">span</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="s">&quot;remove this option&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="nb">String</span>::<span class="n">new</span><span class="p">(),</span><span class="w"></span>
<span class="w">        </span><span class="n">Applicability</span>::<span class="n">MachineApplicable</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">token</span><span class="p">.</span><span class="n">kind</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">token</span>::<span class="n">Comma</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">err</span><span class="p">.</span><span class="n">tool_only_span_suggestion</span><span class="p">(</span><span class="w"></span>
<span class="w">            </span><span class="n">p</span><span class="p">.</span><span class="n">token</span><span class="p">.</span><span class="n">span</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="s">&quot;remove this comma&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="nb">String</span>::<span class="n">new</span><span class="p">(),</span><span class="w"></span>
<span class="w">            </span><span class="n">Applicability</span>::<span class="n">MachineApplicable</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="n">err</span><span class="p">.</span><span class="n">emit</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>But the output is:</p>
<div class="codehilite"><pre><span></span><code>error: the `att_syntax` option was already provided
  --&gt; rust-issue-73193.rs:10:28
   |
10 |             options(nomem, att_syntax, nostack, att_syntax),
   |                            ^^^^^^^^^^
   |
help: remove this option
   |
10 |             options(nomem, , nostack, att_syntax),
   |                           --
</code></pre></div>


<p>When I remove the tool-only suggestion, I get what I would expect for the full thing, which is:</p>
<div class="codehilite"><pre><span></span><code>error: the `att_syntax` option was already provided
  --&gt; rust-issue-73193.rs:10:28
   |
10 |             options(nomem, att_syntax, nostack, att_syntax),
   |                            ^^^^^^^^^^ help: remove this option
</code></pre></div>


<p>Does anyone know why this might be happening? Thanks for your help.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>